function addformworktracker()
{
    $("#addform").append('<div id="feature'+rowdiv+'" class="itPlg addWrkTrckPlug featureclass">'+dataform['worktracker']+"</div>");
var rownow=rowdiv;

   $('#feature'+rownow+' .btndropuser').click(function(){
   
    $('#feature'+rownow+' .popInpAsgn').toggle();
    
   });
   
   $("#feature"+rownow+' input[name="deadWrk[]"]').datepicker(
   {
   dateFormat:'dd/mm/yy'
   }
   ); 
   
   $('#feature'+rownow+' .lstInpTag').click(function(){
   
   var usernameset=$(this).find('input').val();
   
   var originalset=$('#feature'+rownow+' input[name="assignWrk[]"]').val();
   
   originalset=originalset+'#'+usernameset+'  ';
   $('#feature'+rownow+' input[name="assignWrk[]"]').val(originalset);
   $('#feature'+rownow+' .popInpAsgn').hide();
   
   var displaynameset=$(this).find('.txtdisplayname').html();
   var originalset2=$('.inpAddCtnt.inpTagAdd.insertTagdata').val();
   originalset2=originalset2+' #'+displaynameset+'';
   $('.inpAddCtnt.inpTagAdd.insertTagdata').val(originalset2);
   
   
   
   
   
   
   
   
   
   
   
   
   
   });

   $('#feature'+rownow+' .deleterowbutton').click(function(){
   
    $('#feature'+rownow).remove();
    
   });
   
   rowdiv++;

}
function saveformworktracker(id,plugid)
{
        var obj={};
        var pwksid=$("#"+id+'  input[name="pwksid[]"]').val();
        var typeid=$("#"+id+' input[name="typeWrk[]"]:checked').val();
        var name=$("#"+id+'  input[name="nameWrk[]"]').val();
        var enddate=$("#"+id+'  input[name="deadWrk[]"]').val();
        var assign=$("#"+id+'  input[name="assignWrk[]"]').val();
        var priority=$("#"+id+'  input[name="prtWrk[]"]:checked').val();
          if(typeid&&name&&enddate&&assign&&priority)
        {
        obj={plugid:plugid,pwksid:pwksid,typeid:typeid,name:name,enddate:enddate,priority:priority,assign:assign};
        }else
        {
        obj={'code':'22','msg':'Requied Data','error':1};
        }

        return obj;
}
var tempproductcheckwork=0;
var logcheck=0;
function getformworktracker(dataplugin)
{


var arraydata=dataplugin;  

var code='';


var str='';
var allow=0;
if(tempproductcheckwork!=dataplugin['productid'])
{
tempproductcheckwork=dataplugin['productid'];
logcheck=1;
}
if(arraydata['mypost'])
{
allow=1;
}

if(arraydata['userlist'].length)
{
$.each(arraydata['userlist'], function(key, valueuserlist) {

if(useridinfo==valueuserlist['userid'])
{
allow=1;
}
str+='<a href="'+baseinfo+'/'+valueuserlist['username']+'" target="_blank">#'+valueuserlist['displayname']+'</a>  ';

});

}

if(logcheck==1&&allow==1)
{  
code += '<div class="ldIt wrpFrmLd wrpClseWrkTrckLd clBg4">';
code += '<div class="wrpRsv wrpClsWrk">';
code += '<div class="rsvBtnJoin clBgSp2" onclick="closeprojectwork('+arraydata['productid']+')">';
code += '<span class="clTxtW fs11">CLOSED</span>';
code += '</div>';
code += '</div>';
code += '</div>';  

logcheck++;
}
  
code += '<div class="ldIt wrpFrmLd wrpWrkTrckLd clBg4">';
code += '<div class="wrpHdInfoGen mgBtm10">';
code += '<h2 class="clTxt2 fs04 boldGen">Work Tracker</h2>';
code += '</div>';
code += '<table class="tbGenInfo tbFrmLd clTxt3 fs03">';
code += '<tbody>';

code += '<tr><th>Type</th>';

var type='Task';
switch (arraydata['typeid']) {
case '1':
type='Task';
break;
case '2':
type='Problem';
break;
case '3':
type='Request';
break;

}


code += '<td>'+type+'</td>';


code += '</tr>';

code += '<tr>';
code += '<th>Name</th>';
code += '<td>'+arraydata['name']+'</td>';
code += '</tr>';

code += '<tr>';
code += '<th>SKU</th>';
code += '<td>'+arraydata['pwksid']+'</td>';
code += '</tr>';
code += '<tr>';
code += '<th>Assigned To</th>';


code += '<td>'+str+'</td>';


code += '</tr>';
code += '<tr>';
code += '<th>Deadline</th>';



code += '<td>'+arraydata['newdate']+'</td>';
code += '</tr>';
code += '<tr>';
code += '<th>Priority</th>';

type='Low';
switch (arraydata['priority']) {
case '1':
type='Low';
break;
case '2':
type='Normal';
break;
case '3':
type='High';
break;

}

code += '<td>'+type+'</td>';
code += '</tr>';

code += '<tr>';
code += '<th>Status</th>';
code += '<td>';
var checked='';
var text='Not Done';
if(arraydata['status']!='0')
{
text='Done';
checked='checked="checked"';
}
if(allow)
{
code += '<input type="checkbox" '+checked+' class="inpCbWrk done-'+arraydata['pwksid']+'" onclick="changestatusworktracker('+arraydata['pwksid']+','+arraydata['productid']+',1)" >';
}
code += '<label for="donework">'+text+'</label>';
code += '</td>';
code += '</tr>';

code += '<tr>';
code += '<th>Testing</th>';
code += '<td>';

checked='';
text='Not TEST';
if(arraydata['testing']!='0')
{
text='TESTED';
checked='checked="checked"';
}
if(allow)
{
code += '<input type="checkbox" '+checked+' class="inpCbWrk tested-'+arraydata['pwksid']+'" onclick="changestatusworktracker('+arraydata['pwksid']+','+arraydata['productid']+',2)"  >';
}
code += '<label for="tested">'+text+' (For Tester)</label>';
code += '</td>';
code += '</tr>';

code += '</tbody></table>';
code += '</div>';


  

  

return code;


}
function closeprojectwork(productid)
{
var parem=new Array();
parem[0]=productid;

loaddata();
$.post(serviceinfo+'postmedthodplugin', { classset:'worktracker',medthodset:'closeprojectwork',parem:parem }, function(data) { 
loadclosedata();

if(data.error.response)
{

boxmsgdata(data.error.error);

//alertboxtext(data.error.error,$("#validateerror-login"));

}else
{
boxmsgdata('Success');
//$('#txtbroadcast2').val('');
//location.href=baseinfo;


}



});

}
function changestatusworktracker(pwksid,productid,type)
{
var parem=new Array();
parem[0]=pwksid;
parem[1]=productid;
parem[2]=type;
loaddata();
$.post(serviceinfo+'postmedthodplugin', { classset:'worktracker',medthodset:'changestatusworktracker',parem:parem }, function(data) { 
loadclosedata();

if(data.error.response)
{

boxmsgdata(data.error.error);

//alertboxtext(data.error.error,$("#validateerror-login"));

}else
{
boxmsgdata('Success');
//$('#txtbroadcast2').val('');
//location.href=baseinfo;


}



});

}
function editformworktracker(datarow)
{
       addformworktracker();

       var rownow= rowdiv-1;
       
       
       
       $('#feature'+rownow+' input[name="typeWrk[]"]').filter('[value='+datarow.typeid+']').prop('checked', true);
       $('#feature'+rownow+' input[name="nameWrk[]"]').val(datarow.name);
       var str='';
       if(datarow['userlist'].length)
       {
            $.each(datarow['userlist'], function(key, valueuserlist) {


            str+='#'+valueuserlist['username']+' ';

            });

       }
       
       $('#feature'+rownow+' input[name="assignWrk[]"]').val(str);
       $('#feature'+rownow+' input[name="deadWrk[]"]').val(datarow.newdate);
       $('#feature'+rownow+' input[name="prtWrk[]"]').filter('[value='+datarow.priority+']').prop('checked', true);
       $('#feature'+rownow+' input[name="pwksid[]"]').val(datarow.pwksid);


}
